local w = require 'utils.win'
local t = require 'utils.table'

local M = {}

local _close_doc_win = function()
    local win_ids = w.get_window_id_list()
    local current_win_id = w.get_current_window_id()
    t.foreach(win_ids,function(win_id,_)
        if win_id ~= current_win_id then
            w.close(win_id)
        end
    end)
end

M.on_attach = function(ev)
    local bufmap = function(mode, lhs, rhs)
        local opts = {buffer = ev.buf}
        vim.keymap.set(mode, lhs, rhs, opts)
    end

    bufmap('n', '<C-h>', _close_doc_win)
    bufmap('i', '<C-h>', _close_doc_win)
end

return M
-- EOP

